<?php

namespace App\Models\UCenter;

use Illuminate\Database\Eloquent\Model;

class Complain extends Model
{
    protected $table = "complain";
    protected $status_text     = [0 => '未处理', 1 => '已处理'];
    protected $complain_status     = [0 => '未回复', 1 => '同意',2 => '不同意'];
    protected $reply_status     = [0 => '未处理', 1 => '已处理'];
    protected $result     = [0 => '未处理',1 => '订单继续', 2 => '订单取消'];

    public function waybill(){
        return $this->belongsTo('App\Models\Cargo\WayBill','number','number');
    }

    public function ouser(){
        return $this->hasManyThrough('App\Models\User\User', 'App\Models\Cargo\WayBill', 'number','id','number','owner_id');
    }

    public function getReplyStatusAttribute($key)
    {
/*        if($this['reply_status']) {
            return $this->reply_status[$this['reply_status']];
        }else{
            return $this->reply_status[0];
        }*/
        return $this->reply_status[$key];
    }

 //   public function getReplyStatusAttribute($key)
   // {
//        if($this['reply_status']) {
//            return $this->reply_status[$this['reply_status']];
//        }else{
//            return $this->reply_status[0];
//        }
     //   return $this->reply_status[$key];
   // }

    public function getComplainStatusAttribute($key)
    {
        return $this->complain_status[$key];
    }

    public function getResultAttribute($key)
    {
        return $this->result[$key];
    }

}
